package com.boco.dao;

import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.UsernamePasswordCredentials;
import org.apache.commons.httpclient.auth.AuthScope;
import org.apache.commons.httpclient.methods.PostMethod;
import org.apache.commons.httpclient.methods.StringRequestEntity;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.boco.action.InsertEMR_XYCFDataAction;

public class SentData {
	private static final Log log = LogFactory.getLog(SentData.class);
	 public static String sendPost(String url,String param,String userName,String password) {  
	        String result = "Error";
	    	try {
				HttpClient client = new HttpClient();  
				client.getState().setCredentials(AuthScope.ANY, new UsernamePasswordCredentials(userName, password));  
				  
				PostMethod method = new PostMethod(url);  
				method.setRequestHeader("Content-Type", "application/soap+xml;charset=utf-8;action=\"generateLabel\"");  
				log.info(param);
				StringRequestEntity requestEntity = new StringRequestEntity(param, "text/xml", "UTF-8");  
				method.setRequestEntity(requestEntity);
				int code = client.executeMethod(method); 
				
//				System.out.println(code);
//				System.out.println(method.getResponseBodyAsString());
				
				result = method.getResponseBodyAsString();
			} catch (Exception e) {
				e.printStackTrace();
			} 
	    	return result;
	    }
}
